Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: wait for pods and deployments #193

Merged
merged 2 commits into from
Mar 8, 2024
Merged

e2e: wait for pods and deployments #193

merged 2 commits into from
Mar 8, 2024

Conversation

burgerdev
Copy link
Contributor

No description provided.

@burgerdev burgerdev force-pushed the burgerdev/only-portforward branch 2 times, most recently from 96bc6c9 to 0447ca4 Compare March 5, 2024 15:27
Base automatically changed from burgerdev/only-portforward to main March 5, 2024 15:39
@burgerdev burgerdev force-pushed the burgerdev/e2e-deploy branch 2 times, most recently from 0657a2c to 9cacfd4 Compare March 7, 2024 11:40
@burgerdev burgerdev changed the title e2e: deploy unstructured YAML e2e: wait for pods and deployments Mar 7, 2024
@burgerdev burgerdev force-pushed the burgerdev/e2e-deploy branch from 9cacfd4 to f3db4c6 Compare March 7, 2024 11:51
@burgerdev burgerdev marked this pull request as ready for review March 7, 2024 11:52
@burgerdev burgerdev requested a review from katexochen as a code owner March 7, 2024 11:52
@burgerdev burgerdev requested a review from 3u13r March 7, 2024 11:52
Copy link
Member

@katexochen katexochen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally unrelated: When renaming flags, I've noticed that the way we are currently using flags in the e2e isn't great, as it isn't connected to the cli flags on a code level:

		verify := cmd.NewVerifyCmd()
		verify.SetArgs([]string{
			"--output", output,
			"--coordinator-policy-hash=", // TODO(burgerdev): enable policy checking
			"--coordinator", coordinator,
		})

Not sure how we can do better, maybe we could use the verifyFlags struct when defining flags? Not sure how to set them from there (there is pflags.FlagSet.Set etc..)

e2e/internal/kubeclient/deploy.go Outdated Show resolved Hide resolved
e2e/internal/kubeclient/deploy.go Show resolved Hide resolved
@burgerdev burgerdev force-pushed the burgerdev/e2e-deploy branch from f3db4c6 to f6268e1 Compare March 8, 2024 08:55
@burgerdev
Copy link
Contributor Author

totally unrelated: When renaming flags, I've noticed that the way we are currently using flags in the e2e isn't great, as it isn't connected to the cli flags on a code level:

This is also a feature: if a flag changes, that's most likely a breaking change we want to catch! As a replacement for the just/bash/kubectl tests, it makes sense to pass flags independent of their definition in code.

But you're right that this is not what we want when we don't test user expectations, but do internal setup. Another facet of this is output: in the tests, I would sometimes prefer to get a go object instead of a file path (e.g. certs from verify, a manifest from generate, etc.).

What do you think about composing the runE of a command layer and a logic layer - like this (for a hypothetical implementation of ls -a):

func NewCmd() *cobra.Command {
	cmd := &cobra.Command{
		RunE: runE,
	}
	cmd.Flags().BoolP("all", "a", false, "list hidden files too")
	return cmd
}

type flags struct {
	all bool
}

func runE(cmd *cobra.Command, args []string) error {
	flags, _ := parseFlags(cmd)
	fileNames, _ := runInternal(flags)
	for _, fileName := range filenames {
		fmt.Fprintf(cmd.OutOrStdout(). "%s\n", fileName)
	}
}

func runInternal(f *flags) ([]string, error) {
	// run business logic
}

func parseFlags(cmd) (*flags, error) {
	// ...
}

And then we'd use the internal variant when we want the utility, but the command variant when we want to test externally observable behaviour.

@katexochen
Copy link
Member

This is also a feature: if a flag changes, that's most likely a breaking change we want to catch!

That's a good point.

Another facet of this is output: in the tests, I would sometimes prefer to get a go object instead of a file path (e.g. certs from verify, a manifest from generate, etc.).

I thought about that, too, and I use something like this in the sync server implementation. However, this introduces a hard restrictions on the output timing. In Constellation, we had/have situations where the timing of writing something to FS is of importance and cannot be done after the business logic is done, e.g., when the file should also be written in case of an error. It is difficult to keep the runE wrapper flat for complex programs.

@burgerdev burgerdev merged commit a6302b6 into main Mar 8, 2024
6 checks passed
@burgerdev burgerdev deleted the burgerdev/e2e-deploy branch March 8, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants